package org.example.cloudprviderpayment8001.service.imp;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.example.cloudprviderpayment8001.annotion.DataSource;
import org.example.cloudprviderpayment8001.mapper.StudentMapper;
import org.example.cloudprviderpayment8001.pojo.Student;
import org.example.cloudprviderpayment8001.service.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@DataSource("master")
@Service
public class StudentServiceImp extends ServiceImpl<StudentMapper,Student> implements StudentService {
    @Autowired
    private StudentMapper studentMapper;

    @Override
    public Student findAllStudentOne(Integer id) {
        return studentMapper.findAllOne(id);
    }

    @Override
    public List<Student> findAllStudentById(Integer id, String name) {
        return studentMapper.findAllById(id,name);
    }

    @Override
    public List<Student> findAllStudent(Integer id) {
        QueryWrapper<Student> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("id",id);
        return studentMapper.selectList(queryWrapper);
    }

    @Override
    public List<Student> findAllStudentSecond(int age, String name) {
        return studentMapper.findAll(age,name);
    }

    @Override
    public void deleteById(Integer id){
        studentMapper.deleteStudentById(id);
    }

    @Override
    public List<Student> findAll() {
        return studentMapper.selectList(null);
    }

    @Override
    public List<Student> findAllByIdXml(String name) {
        return studentMapper.findByIdMapperXml(name);
    }

    @Override
    public List<Student> findAllByIdXml2(int id) {
        return studentMapper.findByIdMapperXml2(id);
    }
}
